﻿@*
//------------------------------------------------------------------------------
//  此代码版权声明为全文件覆盖，如有原作者特别声明，会在下方手动补充
//  此代码版权（除特别声明外的代码）归作者本人Diego所有
//  源代码使用协议遵循本仓库的开源协议及附加协议
//  Gitee源代码仓库：https://gitee.com/diego2098/ThingsGateway
//  Github源代码仓库：https://github.com/kimdiego2098/ThingsGateway
//  使用文档：https://diego2098.gitee.io/thingsgateway-docs/
//  QQ群：605534569
//------------------------------------------------------------------------------
*@

@page "/tgruntime/devicestatus"
@namespace ThingsGateway.Web.Page
@using System.Linq.Expressions;
@using BlazorComponent;
@using Mapster;
@using Masa.Blazor.Presets;
@using System.IO;
@using TouchSocket.Core;
@inject ICollectDeviceService CollectDeviceService
@inject IUploadDeviceService UploadDeviceService

@attribute [Authorize]
@inject MasaBlazor MasaBlazor
@attribute [RolePermission]
@inherits CultureComponentBase
@inject UserResoures UserResoures
@inject NavigationManager NavigationManager
@inject IDriverPluginService DriverPluginService
@layout MainLayout
<MSheet Style="overflow:auto">


    <MTabs @bind-Value="tab">
        <MTab Style="height:50px;">
            @T("采集设备状态")
        </MTab>
        <MTab Style="height:50px;">
            @T("上传设备状态")
        </MTab>
        <MTab Style="height:50px;">
            @T("其他服务状态")
        </MTab>
    </MTabs>
    <MTabsItems Value="tab">
        <MTabItem>
            <MRow NoGutters>
                <MCol Md=2 Cols="12">
                    <MCard Class="ma-2" Style="height: calc(100vh - 210px)">
                        <MCardTitle>
                            <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_collectDeviceGroupSearchName"
                                        Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.DeviceGroup)) />
                        </MCardTitle>
                        <MTreeview Style="height: calc(100vh - 370px);overflow-y:auto" Dense TItem="string" TKey="string" ActiveChanged=@(async a=>
                                   {
                                   if(_collectDeviceGroup!=a.FirstOrDefault())
                                   {
                                   _collectDeviceGroup=a.FirstOrDefault(); collectDeviceQuery();
                                   }
                                   } )
                                   Items="_collectDeviceGroups" ItemText="r=>r" ItemChildren="r=>null"
                                   Search="@_collectDeviceGroupSearchName"
                                   Activatable ItemKey=@(r=>r)>
                        </MTreeview>
                    </MCard>
                </MCol>
                <MCol Md=3 Cols="12">
                    <MCard Height=@("calc(100vh - 210px)") Style="overflow-y:auto;" Flat Class="ml-2 my-4">

                        <MVirtualScroll Context="item" Height=@("calc(100vh - 230px)") OverscanCount=2 ItemSize="60" Items="_collectDeviceCores">

                            <ItemContent>
                                @if (item.Device != null)
                                {

                                    <MListItem OnClick=@(()=>collectDeviceInfo(item))>
                                        <MListItemContent>
                                            <MListItemTitle>
                                                <MLabel Class=@((item.Device?.DeviceStatus==DeviceStatusEnum.OnLine?"green--text":"red--text")+$" text-h6")>
                                                    <div class="mt-1  d-flex align-center justify-space-between">
                                                        <span>@item.Device?.Name</span>
                                                        <span style="white-space: nowrap !important;overflow: hidden !important; text-overflow: ellipsis !important;" class="text-caption">@(item.Device?.ActiveTime.Add(JsInitVariables.TimezoneOffset).ToString("yyyy-MM-dd HH:mm:ss fff") + "     " + typeof(DeviceStatusEnum).GetDescription(item.Device?.DeviceStatus.ToString()))</span>
                                                    </div>
                                                </MLabel>
                                            </MListItemTitle>
                                        </MListItemContent>

                                    </MListItem>

                                    <MDivider></MDivider>

                                }

                            </ItemContent>
                        </MVirtualScroll>


                    </MCard>

                </MCol>
                <MCol Md=7 Cols="12">
                    <MCard Style="height: calc(100vh - 210px) ;overflow:auto" Flat Elevation="0">
                        @if (collectDeviceInfoItem != null && collectDeviceInfoItem?.Device != null)
                        {
                            var item = collectDeviceInfoItem;
                            <MCard Style="height:300px;overflow:auto;" Flat Class="ml-4 my-4 ma-2" Elevation="0">

                                <MCardActions>
                                    <div class="mr-12"></div>

                                    <MLabel Class=@((item.Device?.DeviceStatus==DeviceStatusEnum.OnLine?"green--text":"red--text")+$" text-h6")>
                                        <div class="mt-1  d-flex align-center justify-space-between">
                                            <span class="mx-3">@item.Device?.Name</span>
                                            <span style="white-space: nowrap !important;overflow: hidden !important; text-overflow: ellipsis !important;" class="text-caption mx-3">@(item.Device?.ActiveTime.Add(JsInitVariables.TimezoneOffset).ToString("yyyy-MM-dd HH:mm:ss fff") + "     " + typeof(DeviceStatusEnum).GetDescription(item.Device?.DeviceStatus.ToString()))</span>
                                        </div>
                                    </MLabel>

                                    <MSpacer></MSpacer>
                                    <MTooltip Bottom Context="tip">
                                        <ActivatorContent>
                                            <MButton Disabled=@(!UserResoures.IsHasPageWithRole("/tgruntime/devicevariable")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small Loading=isRestart
                                                     OnClick=@(()=>NavigationManager.NavigateTo("/tgruntime/devicevariable?devicename="+item.Device?.Name))>
                                                <MIcon>mdi-information-outline</MIcon>
                                            </MButton>
                                        </ActivatorContent>
                                        <ChildContent>
                                            <span>@T("相关变量")</span>
                                        </ChildContent>
                                    </MTooltip>


                                    <MTooltip Bottom Context="tip">
                                        <ActivatorContent>
                                            <MButton Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicepause")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small OnClick=@(()=>Config(item.DeviceId,!item.Device?.KeepRun))>
                                                <MIcon>@(item.Device?.KeepRun == true ? "mdi-pause" : "mdi-play")</MIcon>
                                                </MButton>
                                            </ActivatorContent>
                                            <ChildContent>
                                                <span>@(item.Device?.KeepRun == true ? T("暂停") : T("运行"))</span>
                                        </ChildContent>
                                    </MTooltip>
                                    <MTooltip Bottom Context="tip">
                                        <ActivatorContent>
                                            <MButton Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicerestart")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small Loading=isRestart OnClick=@(()=>Restart(item.DeviceId))>
                                                <MIcon>mdi-restart</MIcon>
                                            </MButton>
                                        </ActivatorContent>
                                        <ChildContent>
                                            <span>@T("重启")</span>
                                        </ChildContent>
                                    </MTooltip>

                                </MCardActions>

                                <MSubheader>
                                    运行状态
                                </MSubheader>
                                <MRow Class="ml-2 mr-2 d-flex" NoGutters>
                                <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.ActiveTime)</span>
                                    <span class="text-caption">@item.Device?.ActiveTime.Add(JsInitVariables.TimezoneOffset).ToString("yyyy-MM-dd HH:mm:ss fff")</span>
                                </MCol>
                                <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.SourceVariableCount)</span>
                                    <span class="text-caption">@item.Device?.SourceVariableCount</span>
                                </MCol>
                                <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.DeviceVariableCount)</span>
                                    <span class="text-caption">@item.Device?.DeviceVariableCount</span>
                                </MCol>
                                <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.MethodVariableCount)</span>
                                    <span class="text-caption">@item.Device?.MethodVariableCount</span>
                                </MCol>
                                <MCol Md=12 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.LastErrorMessage)</span>
                                    <span class="text-caption red--text">@item.Device?.LastErrorMessage</span>
                                </MCol>
                            </MRow>

                            <MSubheader>
                                配置信息
                            </MSubheader>
                            <MRow Class="ml-2 mr-2 d-flex" NoGutters>
                                <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.PluginName)</span>
                                    <span class="text-caption">@item.Device?.PluginName</span>
                                </MCol>
                                <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.IsLogOut)</span>
                                    <span class="text-caption">@item.Device?.IsLogOut</span>
                                </MCol>
                                @foreach (var property in item.Device?.DevicePropertys ?? new())
                                    {
                                        <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                            <span class="text-subtitle-2 grey--text">@property.Description</span>
                                            <span class="text-caption ">@(property.PropertyName.Contains("Password") ? "******" : @property.Value)</span>
                                        </MCol>
                                    }

                                </MRow>


                            </MCard>
                        }

                        <MCard Flat Class="ml-4">
                            @if (collectDeviceInfoItem != null && collectDeviceInfoItem?.Device != null)
                            {
                                <MCardActions>
                                    报文日志（共享链路的日志也会相同）
                                    <MSpacer></MSpacer>

                                    <MTooltip Bottom Context="tip">
                                        <ActivatorContent>
                                            <MButton Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicepause")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small
                                                     OnClick=@(()=>
                                                 {
                                                 pauseMessage=!pauseMessage;
                                                 if(pauseMessage)
                                                 CurMessages= collectDeviceInfoItem.Driver?.Messages.ToList();
                                                 }
                                                 )>
                                                <MIcon>@((!pauseMessage) ? "mdi-pause" : "mdi-play")</MIcon>
                                                </MButton>
                                            </ActivatorContent>
                                            <ChildContent>
                                                <span>@((!pauseMessage) ? T("暂停日志") : T("运行日志"))</span>
                                        </ChildContent>
                                    </MTooltip>

                                    <MTooltip Bottom Context="tip">
                                        <ActivatorContent>
                                            <MButton Loading=isDownExport Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicepause")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small
                                                     OnClick=@(async()=>
                                                 {
                                                 var curMessages= collectDeviceInfoItem.Driver?.Messages.ToList();
                                                 await DownDeviceMessageExport(curMessages);
                                                 }
                                                 )>
                                                <MIcon>mdi-export</MIcon>
                                            </MButton>
                                        </ActivatorContent>
                                        <ChildContent>
                                            <span>@T("导出")</span>
                                        </ChildContent>
                                    </MTooltip>

                                </MCardActions>
                                {
                                    ICollection<string> item = null;
                                    if (pauseMessage)
                                    {
                                        item = CurMessages;
                                    }
                                    else if (collectDeviceInfoItem.Driver != null)
                                    {
                                        item = collectDeviceInfoItem.Driver?.Messages;
                                    }
                                    if(item==null)
                                    {
                                        item = new List<string>();
                                    }
                                    <MRow Class="ml-2 mr-2 d-flex" NoGutters>
                                    <MVirtualScroll Context="itemMessage" TItem="string" Height=@("calc(100vh - 600px)") OverscanCount=2 ItemSize="100" Items="item">
                                        <ItemContent>
                                            <div>
                                                @itemMessage
                                            </div>
                                        </ItemContent>
                                    </MVirtualScroll>
                                </MRow>
                                }

                            }
                        </MCard>

                    </MCard>
                </MCol>
            </MRow>
        </MTabItem>
        <MTabItem>
            <MRow>
                <MCol Md=2 Cols="12">
                    <MCard Class="ma-2" Style="height: calc(100vh - 210px)">
                        <MCardTitle>
                            <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_uploadDeviceGroupSearchName"
                                        Outlined Label=@typeof(UploadDevice).GetDescription(nameof(UploadDevice.DeviceGroup)) />
                        </MCardTitle>
                        <MTreeview Style="height: calc(100vh - 370px);overflow-y:auto" Dense TItem="string" TKey="string" ActiveChanged=@(async a=>
                                   {
                                   if(_uploadDeviceGroup!=a.FirstOrDefault())
                                   {
                                   _uploadDeviceGroup=a.FirstOrDefault(); uploadDeviceQuery();
                                   }
                                   } )
                                   Items="_uploadDeviceGroups" ItemText="r=>r" ItemChildren="r=>null"
                                   Search="@_uploadDeviceGroupSearchName"
                                   Activatable ItemKey=@(r=>r)>
                        </MTreeview>
                    </MCard>
                </MCol>
                <MCol Md=3 Cols="12">
                    <MCard Height=@("calc(100vh - 210px)") Style="overflow-y:auto;" Flat Class="ml-2 my-4">

                        <MVirtualScroll Context="item" Height=@("calc(100vh - 230px)") OverscanCount=2 ItemSize="60" Items="_uploadDeviceCores">

                            <ItemContent>
                                @if (item.Device != null)
                                {

                                    <MListItem OnClick=@(()=>uploadDeviceInfo(item))>
                                        <MListItemContent>
                                            <MListItemTitle>
                                                <MLabel Class=@((item.Device?.DeviceStatus==DeviceStatusEnum.OnLine?"green--text":"red--text")+$" text-h6")>
                                                    <div class="mt-1  d-flex align-center justify-space-between">
                                                        <span>@item.Device?.Name</span>
                                                        <span style="white-space: nowrap !important;overflow: hidden !important; text-overflow: ellipsis !important;" class="text-caption">@(item.Device?.ActiveTime.Add(JsInitVariables.TimezoneOffset).ToString("yyyy-MM-dd HH:mm:ss fff") + "     " + typeof(DeviceStatusEnum).GetDescription(item.Device?.DeviceStatus.ToString()))</span>
                                                    </div>
                                                </MLabel>
                                            </MListItemTitle>
                                        </MListItemContent>

                                    </MListItem>

                                    <MDivider></MDivider>

                                }

                            </ItemContent>
                        </MVirtualScroll>


                    </MCard>

                </MCol>
                <MCol Md=7 Cols="12">
                    <MCard Style="height: calc(100vh - 210px) ;overflow:auto" Flat Elevation="0">
                        @if (uploadDeviceInfoItem != null && uploadDeviceInfoItem?.Device != null)
                        {
                            var item = uploadDeviceInfoItem;
                            <MCard Style="height:300px;overflow:auto;" Flat Class="ml-4 my-4 ma-2" Elevation="0">

                                <MCardActions>
                                    <div class="mr-12"></div>

                                    <MLabel Class=@((item.Device?.DeviceStatus==DeviceStatusEnum.OnLine?"green--text":"red--text")+$" text-h6")>
                                        <div class="mt-1  d-flex align-center justify-space-between">
                                            <span class="mx-3">@item.Device?.Name</span>
                                            <span style="white-space: nowrap !important;overflow: hidden !important; text-overflow: ellipsis !important;" class="text-caption mx-3">@(item.Device?.ActiveTime.Add(JsInitVariables.TimezoneOffset).ToString("yyyy-MM-dd HH:mm:ss fff") + "     " + typeof(DeviceStatusEnum).GetDescription(item.Device?.DeviceStatus.ToString()))</span>
                                        </div>
                                    </MLabel>

                                    <MSpacer></MSpacer>
                                    <MTooltip Bottom Context="tip">
                                        <ActivatorContent>
                                            <MButton Disabled=@(!UserResoures.IsHasPageWithRole("/tgruntime/devicevariable")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small Loading=isRestart
                                                     OnClick=@(()=>NavigationManager.NavigateTo("/tgruntime/devicevariable?devicename="+item.Device?.Name))>
                                                <MIcon>mdi-information-outline</MIcon>
                                            </MButton>
                                        </ActivatorContent>
                                        <ChildContent>
                                            <span>@T("相关变量")</span>
                                        </ChildContent>
                                    </MTooltip>


                                    <MTooltip Bottom Context="tip">
                                        <ActivatorContent>
                                            <MButton Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicepause")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small OnClick=@(()=>Config(item.DeviceId,!item.Device?.KeepRun))>
                                                <MIcon>@(item.Device?.KeepRun == true ? "mdi-pause" : "mdi-play")</MIcon>
                                                </MButton>
                                            </ActivatorContent>
                                            <ChildContent>
                                                <span>@(item.Device?.KeepRun == true ? T("暂停") : T("运行"))</span>
                                        </ChildContent>
                                    </MTooltip>
                                    <MTooltip Bottom Context="tip">
                                        <ActivatorContent>
                                            <MButton Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicerestart")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small Loading=isRestart OnClick=@(()=>Restart(item.DeviceId))>
                                                <MIcon>mdi-restart</MIcon>
                                            </MButton>
                                        </ActivatorContent>
                                        <ChildContent>
                                            <span>@T("重启")</span>
                                        </ChildContent>
                                    </MTooltip>

                                </MCardActions>

                                <MSubheader>
                                    运行状态
                                </MSubheader>
                                <MRow Class="ml-2 mr-2 d-flex" NoGutters>
                                <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.ActiveTime)</span>
                                    <span class="text-caption">@item.Device?.ActiveTime.Add(JsInitVariables.TimezoneOffset).ToString("yyyy-MM-dd HH:mm:ss fff")</span>
                                </MCol>
                                <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.UploadVariableCount)</span>
                                    <span class="text-caption">@item.Device?.UploadVariableCount</span>
                                </MCol>
                                <MCol Md=12 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.LastErrorMessage)</span>
                                    <span class="text-caption red--text">@item.Device?.LastErrorMessage</span>
                                </MCol>
                            </MRow>

                            <MSubheader>
                                配置信息
                            </MSubheader>
                            <MRow Class="ml-2 mr-2 d-flex" NoGutters>
                                <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.PluginName)</span>
                                    <span class="text-caption">@item.Device?.PluginName</span>
                                </MCol>
                                <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                    <span class="text-subtitle-2 grey--text">@item.Device?.Description(a=>a.IsLogOut)</span>
                                    <span class="text-caption">@item.Device?.IsLogOut</span>
                                </MCol>
                                @foreach (var property in item.Device?.DevicePropertys ?? new())
                                    {
                                        <MCol Md=6 Cols="12" Class="px-4 mt-1  d-flex align-center justify-space-between">
                                            <span class="text-subtitle-2 grey--text">@property.Description</span>
                                            <span class="text-caption ">@(property.PropertyName.Contains("Password") ? "******" : @property.Value)</span>
                                        </MCol>
                                    }

                                </MRow>


                            </MCard>
                        }

                        <MCard Flat Class="ml-4">
                            @if (uploadDeviceInfoItem != null && uploadDeviceInfoItem?.Device != null)
                            {
                                <MCardActions>
                                    报文日志（共享链路的日志也会相同）
                                    <MSpacer></MSpacer>

                                    <MTooltip Bottom Context="tip">
                                        <ActivatorContent>
                                            <MButton Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicepause")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small
                                                     OnClick=@(()=>
                                                 {
                                                 pauseMessage=!pauseMessage;
                                                 if(pauseMessage)
                                                 CurMessages= uploadDeviceInfoItem.Driver?.Messages.ToList();
                                                 }
                                                 )>
                                                <MIcon>@((!pauseMessage) ? "mdi-pause" : "mdi-play")</MIcon>
                                                </MButton>
                                            </ActivatorContent>
                                            <ChildContent>
                                                <span>@((!pauseMessage) ? T("暂停日志") : T("运行日志"))</span>
                                        </ChildContent>
                                    </MTooltip>

                                    <MTooltip Bottom Context="tip">
                                        <ActivatorContent>
                                            <MButton Loading=isDownExport Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicepause")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small
                                                     OnClick=@(async()=>
                                                 {
                                                 var curMessages= uploadDeviceInfoItem.Driver?.Messages.ToList();
                                                 await DownDeviceMessageExport(curMessages);
                                                 }
                                                 )>
                                                <MIcon>mdi-export</MIcon>
                                            </MButton>
                                        </ActivatorContent>
                                        <ChildContent>
                                            <span>@T("导出")</span>
                                        </ChildContent>
                                    </MTooltip>

                                </MCardActions>
                                {
                                    ICollection<string> item = null;
                                    if (pauseMessage)
                                    {
                                        item = CurMessages;
                                    }
                                    else if (uploadDeviceInfoItem.Driver != null)
                                    {
                                        item = uploadDeviceInfoItem.Driver?.Messages ?? new();
                                    }
                                    if (item == null)
                                    {
                                        item = new List<string>();
                                    }
                                    <MRow Class="ml-2 mr-2 d-flex" NoGutters>
                                    <MVirtualScroll Context="itemMessage" TItem="string" Height=@("calc(100vh - 600px)") OverscanCount=2 ItemSize="100" Items="item">
                                        <ItemContent>
                                            <div>
                                                @itemMessage
                                            </div>
                                        </ItemContent>
                                    </MVirtualScroll>
                                </MRow>
                                }

                            }
                        </MCard>

                    </MCard>
                </MCol>
            </MRow>
        </MTabItem>

        <MTabItem>

            <MRow NoGutters>
                <MCard Class="ml-2 my-3" Style="width:100%" Elevation="1">
                    <MCardSubtitle Class=@((AlarmHostService.StatuString.IsSuccess?"green--text":"red--text")+$" text-subtitle-2")>
                        <div class="mt-1  d-flex align-center justify-space-between">
                            <span>@T("历史报警服务状态")</span>
                            <span class="text-caption">@AlarmHostService.StatuString.Message</span>
                        </div>
                    </MCardSubtitle>
                </MCard>
            </MRow>
            <MRow NoGutters>
                <MCard Class="ml-2 my-3" Style="width:100%" Elevation="1">
                    <MCardSubtitle Class=@((HistoryValueHostService.StatuString.IsSuccess?"green--text":"red--text")+$" text-subtitle-2")>
                        <div class="mt-1  d-flex align-center justify-space-between">
                            <span>@T("历史数据服务状态")</span>
                            <span class="text-caption">@HistoryValueHostService.StatuString.Message</span>
                        </div>
                    </MCardSubtitle>
                </MCard>
            </MRow>
            <MRow NoGutters>
                <MCard Class="ml-2 my-3" Style="width:100%" Elevation="1">
                    <MCardSubtitle Class=@((MemoryVariableWorker.StatuString.IsSuccess?"green--text":"red--text")+$" text-subtitle-2")>
                        <div class="mt-1  d-flex align-center justify-space-between">
                            <span>@T("中间变量计算服务状态")</span>
                            <span class="text-caption">@MemoryVariableWorker.StatuString.Message</span>
                        </div>
                    </MCardSubtitle>
                </MCard>
            </MRow>


        </MTabItem>
    </MTabsItems>


    <MSpeedDial @bind-Value="fab" Direction="bottom" Class="position-button"
                Transition="slide-y-reverse-transition">
        <ActivatorContent>
            <MButton Color="blue darken" Dark Small Fab @attributes="@context.Attrs">
                <MIcon Class="position-button-spin">
                    @(fab ? "mdi-close" : "mdi-cog")
                </MIcon>
            </MButton>
        </ActivatorContent>
        <ChildContent>
            <MTooltip Bottom Context="tip">
                <ActivatorContent>
                    <MButton Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicerestart")) Color="red" @attributes="@tip.Attrs" Dark Fab Small Loading=isAllRestart OnClick="AllRestart">
                        <MIcon>   mdi-restart   </MIcon>
                    </MButton>
                </ActivatorContent>
                <ChildContent>
                    <span>@T("全部重启")</span>
                </ChildContent>
            </MTooltip>

        </ChildContent>
    </MSpeedDial>
    <MOverlay Value="isAllRestart" Opacity="0.8">
        <span class="green--text text--darken-2">
            @T("后台服务重启中")
        </span>
        <MProgressCircular Indeterminate Width=8
                           Size="40"></MProgressCircular>
    </MOverlay>
</MSheet>

<style>
    .position-button {
        position: fixed !important;
        top: 10%;
        right: 0;
        box-shadow: 1px 1px 8px var(--mud-palette-primary);
        background-color: var(--mud-palette-primary);
        cursor: pointer
    }

</style>









